home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 526-550 / disk_545 / drawmap / src.lzh / ILBM_lib.h < prev    next >
C/C++ Source or Header  |  1991-09-13  |  25KB  |  659 lines

  1.          /* C Include File for the dissidents ilbm.library */
  2.    /* Set your editor's TAB width to 3 for a ledgible reproduction */
  3.  
  4.    /* This file is meant to replace all IFF include files for ILBM and
  5.       ANIM applications using the ilbm.library */
  6.  
  7.    /*  #define FDwAT  */
  8.  
  9. #ifndef   ILBMLIB_H
  10. #define   ILBMLIB_H
  11.  
  12. #ifndef   GRAPHICS_GFX_H
  13. #include   <graphics/gfx.h>
  14. #endif
  15.  
  16. #ifndef   INTUITION_INTUITION_H
  17. #include   <intuition/intuition.h>
  18. #endif
  19.  
  20. #ifndef LIBRARIES_DOS_H
  21. #include "libraries/dos.h"
  22. #endif
  23.  
  24.    /* ======================== Chunk IDs =============================== */
  25.  
  26. typedef LONG ID;   /* An ID is four printable ASCII chars but
  27.                    stored as a LONG for efficient copy & compare.*/
  28.  
  29. /* Four-character IDentifier builder.*/
  30. #define MakeID(a,b,c,d)  ( (LONG)(a)<<24L | (LONG)(b)<<16L | (c)<<8 | (d) )
  31.  
  32.    /* Standard group IDs.  A chunk with one of these IDs contains a
  33.       SubTypeID followed by zero or more chunks.*/
  34. #define FORM   MakeID('F','O','R','M')
  35. #define PROP   MakeID('P','R','O','P')
  36. #define LIST   MakeID('L','I','S','T')
  37. #define CAT      MakeID('C','A','T',' ')
  38. #define FILLER   MakeID(' ',' ',' ',' ')
  39.  
  40.    /* SubTypeIDs */
  41. #define   ID_ILBM   MakeID('I','L','B','M')
  42. #define   ID_ANIM   MakeID('A','N','I','M')
  43.  
  44.    /* ILBM Chunk IDs */
  45. #define   ID_BMHD   MakeID('B','M','H','D')
  46. #define   ID_CMAP   MakeID('C','M','A','P')
  47. #define   ID_GRAB   MakeID('G','R','A','B')
  48. #define   ID_DEST   MakeID('D','E','S','T')
  49. #define   ID_SPRT   MakeID('S','P','R','T')
  50. #define   ID_CAMG   MakeID('C','A','M','G')
  51. #define   ID_BODY   MakeID('B','O','D','Y')
  52. #define   ID_CRNG   MakeID('C','R','N','G')
  53. #define   ID_CCRT  MakeID('C','C','R','T')
  54.  
  55.    /* ANIM Chunk IDs */
  56. #define   ID_DLTA   MakeID('D','L','T','A')
  57. #define   ID_ANHD   MakeID('A','N','H','D')
  58.  
  59. #define ID_ANFR MakeID('A','N','F','R')
  60. #define ID_MAHD MakeID('M','A','H','D')
  61. #define ID_MFHD MakeID('M','F','H','D')
  62. #define ID_CM16 MakeID('C','M','1','6')
  63. #define ID_ATXT MakeID('A','T','X','T')
  64. #define ID_PTXT MakeID('P','T','X','T')
  65.  
  66.  
  67.    /* =========================== Chunk ============================== */
  68.  
  69. /* All chunks start with a type ID and a count of the data bytes that 
  70.    follow--the chunk's "logical size" or "data size". If that number is odd,
  71.    a 0 pad byte is written, too. */
  72. typedef struct {
  73.     ID     ckID;
  74.     LONG  ckSize;
  75.     } ChunkHeader;
  76.  
  77. typedef struct {
  78.     ID     ckID;
  79.     LONG  ckSize;
  80.     UBYTE ckData[ 1 /*REALLY: ckSize*/ ];
  81.     } Chunk;
  82.  
  83. /* Pass ckSize = szNotYetKnown to the writer to mean "compute the size".*/
  84. #define szNotYetKnown 0x80000001L
  85.  
  86. /* Need to know whether a value is odd so we can word-align.*/
  87. #define IS_ODD(a)   ((a) & 1)
  88.  
  89. /* This macro rounds up to an even number. */
  90. #define WordAlign(size)   ((size+1)&~1)
  91.  
  92. /* ALL CHUNKS MUST BE PADDED TO EVEN NUMBER OF BYTES.
  93.    ChunkPSize computes the total "physical size" of a padded chunk from
  94.    its "data size" or "logical size". */
  95. #define ChunkPSize(dataSize)  (WordAlign(dataSize) + sizeof(ChunkHeader))
  96.  
  97. /* The Grouping chunks (LIST, FORM, PROP, & CAT) contain concatenations of
  98.    chunks after a subtype ID that identifies the content chunks.
  99.    "FORM type XXXX", "LIST of FORM type XXXX", "PROPerties associated
  100.    with FORM type XXXX", or "conCATenation of XXXX".*/
  101. typedef struct {
  102.     ID     ckID;
  103.     LONG  ckSize;   /* this ckSize includes "grpSubID".*/
  104.     ID    grpSubID;
  105.     } GroupHeader;
  106.  
  107. typedef struct {
  108.     ID     ckID;
  109.     LONG  ckSize;
  110.     ID    grpSubID;
  111.     UBYTE grpData[ 1 /*REALLY: ckSize-sizeof(grpSubID)*/ ];
  112.     } GroupChunk;
  113.  
  114.  
  115.    /* ======== IFFP Status code return from the Lib Functions ========= */
  116. typedef LONG IFFP;
  117.    /* Status code result from an IFF procedure. A LONG, because must be
  118.       type compatible with ID for GetChunkHdr. Note that the error codes
  119.       below are not legal IDs. */
  120. #define   IFF_OKAY   0L   /* Keep going...(not end of file, but we haven't found
  121.                      our requested FORM or an error yet). Note that the
  122.                      highest level routines use this to really mean that
  123.                      everything went well. (see LoadIFFToWindow) */
  124. #define   END_MARK   -1L /* Encountered the end of a group (i.e. FORM, LIST, etc).
  125.                   The end of the entire file if you are at the top group.*/
  126. #define   IFF_DONE   -2L /* Returns this when it has READ enough.
  127.                         It means return to application. File is Okay. */
  128. #define   DOS_ERROR -3L /* AmigaDOS Read or Write error. */
  129. #define   NOT_IFF   -4L  /* Not an IFF file. */
  130. #define   NO_FILE   -5L  /* Tried to open file, AmigaDOS didn't find it. */
  131. #define   CLIENT_ERROR -6L  
  132.                      /* Application made invalid request, for instance, write
  133.                      a negative size chunk. */
  134. #define   BAD_FORM   -7L /* A read routine complains about FORM semantics
  135.                      e.g. valid IFF file, but missing a required chunk such
  136.                      as an ILBM without a BMHD chunk. */
  137. #define   SHORT_CHUNK -8L  /* Application asked IFFReadBytes to read more bytes
  138.                          than are left in the chunk. Could be an applic. bug
  139.                          or bad file. */
  140. #define   BAD_IFF    -9L  /* mal-formed IFF file. Found half a chunk? A CAT with
  141.                         a PROP in it? */
  142. #define   IFF_NOTFOUND -10L
  143.                      /* The requested FORM not found within the IFF file
  144.                      (Did you try to find an ILBM in an SMUS file?) */
  145.  
  146. #define   IFF_NOMEM   -11L      /* Out of memory while loading file */
  147. #define   UNKNOWN_ERROR -12L  /* This error is unknown (i.e. not 1 of the
  148.                          preceding). The default lib routines will never
  149.                          return this. Your custom routines could use this
  150.                         to signal your calling code that the custom
  151.                         routine was responsible for terminating. */
  152.  
  153. /* This MACRO is used to RETURN immediately when a termination condition is
  154.    found. This is a pretty weird macro. It requires the caller to declare a
  155.    local "IFFP iffp" and assign it. This wouldn't work as a subroutine since
  156.    it returns for it's caller. */
  157. #define CheckIFFP()   { if (iffp != IFF_OKAY) return(iffp); }
  158.  
  159.  
  160.    /* =================== Context STRUCTURE ===================== */
  161.  
  162. typedef struct _GroupContext {
  163.    struct _GroupContext *parent; /* Containing group; NULL => whole file. */
  164.    ULONG   conUserData;            /* For the application's use */
  165.    BPTR   file;                     /* Byte-stream file handle. */
  166.    LONG   position;               /* The context's logical file position. */
  167.    LONG   bound;                  /* File-absolute context bound
  168.                                      or szNotYetKnown (writer only). */
  169.    ChunkHeader ckHdr;
  170.                      /* Current chunk header. ckHdr.ckSize = szNotYetKnown
  171.                       means we need to go back and set the size (writer only).
  172.                       See also Pseudo-IDs, above. */
  173.     ID   subtype;                  /* Group's subtype ID when reading. */
  174.     LONG   bytesSoFar;      /* # bytes read/written of current chunk's data. */
  175.     } GroupContext;
  176.  
  177. /* Computes the number of bytes not yet read from the current chunk, given
  178.    a group read context gc. */
  179. #define ChunkMoreBytes(gc)  ((gc)->ckHdr.ckSize - (gc)->bytesSoFar)
  180.  
  181.  
  182.    /* =================== BitMapHeader (BMHD Chunk) ================== */
  183.  
  184. typedef UBYTE Masking;      /* Choice of masking technique.*/
  185. #define mskNone                 0
  186. #define mskHasMask              1
  187. #define mskHasTransparentColor  2
  188. #define mskLasso                3
  189.  
  190. typedef UBYTE Compression;   /* Choice of compression algorithm applied to
  191.      * each row of the source and mask planes. "cmpByteRun1" is the byte run
  192.      * encoding generated by Mac's PackBits. */
  193. #define cmpNone      0
  194. #define cmpByteRun1  1
  195.  
  196. /* Aspect ratios: The proper fraction xAspect/yAspect represents the pixel
  197.    aspect ratio pixel_width/pixel_height.
  198.  
  199.    For the 4 Amiga display modes:
  200.       320 x 200: 10/11  (these pixels are taller than they are wide)
  201.       320 x 400: 20/11
  202.       640 x 200:  5/11
  203.       640 x 400: 10/11      */
  204. #define x320x200Aspect 10
  205. #define y320x200Aspect 11
  206. #define x320x400Aspect 20
  207. #define y320x400Aspect 11
  208. #define x640x200Aspect  5
  209. #define y640x200Aspect 11
  210. #define x640x400Aspect 10
  211. #define y640x400Aspect 11
  212.  
  213. /* A BitMapHeader is stored in a BMHD chunk. */
  214. typedef struct {
  215.     UWORD w, h;         /* raster width & height in pixels */
  216.     WORD  x, y;         /* position for this image */
  217.     UBYTE nPlanes;      /* # source bitplanes */
  218.     Masking masking;      /* masking technique */
  219.     Compression compression;   /* compression algoithm */
  220.     UBYTE pad1;         /* UNUSED.  For consistency, put 0 here.*/
  221.     UWORD transparentColor;   /* transparent "color number" */
  222.     UBYTE xAspect, yAspect;   /* aspect ratio, a rational number x/y */
  223.     WORD  pageWidth, pageHeight;  /* source "page" size in pixels */
  224.     } BitMapHeader;
  225.  
  226.  
  227. /* RowBytes computes the number of bytes in a row, from the width in pixels.*/
  228. #define RowBytes(w)   (((w) + 15) >> 4 << 1)
  229.  
  230.  
  231.    /* ==================== ColorRegister ========================== */
  232.    /* A CMAP chunk is a packed array of ColorRegisters (3 bytes each). */
  233.  
  234. typedef struct {
  235.     UBYTE red, green, blue; /* MUST be UBYTEs so ">> 4" won't sign extend.*/
  236.     } ColorRegister;
  237.  
  238. /* Use this constant instead of sizeof(ColorRegister). */
  239. #define sizeofColorRegister  3
  240.  
  241. typedef WORD Color4;   /* Amiga RAM version of a color-register,
  242.                         with 4 bits each RGB in low 12 bits.*/
  243.  
  244. /* Maximum number of bitplanes in RAM. Current Amiga max w/dual playfield. */
  245. #define   MaxAmDepth   6
  246.  
  247. /* Maximum number of color regs in amiga colorTable */
  248. #define   maxColorReg   32
  249.  
  250.  
  251.    /* ========================= Point2D ============================== */
  252.    /* A Point2D is stored in a GRAB chunk. */
  253.  
  254. typedef struct {
  255.     WORD x, y;      /* coordinates (pixels) */
  256.     } Point2D;
  257.  
  258.    /* ========================= DestMerge ============================ */
  259.    /* A DestMerge is stored in a DEST chunk. */
  260.  
  261. typedef struct {
  262.     UBYTE depth;   /* # bitplanes in the original source */
  263.     UBYTE pad1;      /* UNUSED; for consistency store 0 here */
  264.     UWORD planePick;   /* how to scatter source bitplanes into destination */
  265.     UWORD planeOnOff;   /* default bitplane data for planePick */
  266.     UWORD planeMask;   /* selects which bitplanes to store into */
  267.     } DestMerge;
  268.  
  269.    /* ====================== SpritePrecedence ======================== */
  270.    /* A SpritePrecedence is stored in a SPRT chunk. */
  271.  
  272. typedef UWORD SpritePrecedence;
  273.  
  274.    /* ======================= Viewport Mode =========================== */
  275.    /* A Commodore Amiga ViewPort->Modes is stored in a CAMG chunk. The
  276.        chunk's content is declared as a LONG. */
  277.  
  278. typedef struct {
  279.    ULONG   ViewModes;
  280.    } CamgChunk;
  281.  
  282.    /* ======================== CRNG =============================== */
  283.  
  284. #define   maxCycles   8
  285. #define   RNG_NORATE   36         /* Dpaint uses this rate to mean non-active */
  286.  
  287. typedef struct {
  288.    WORD   pad1;      /* future exp - store 0 here */
  289.    WORD   rate;      /* 60/sec=16384, 30/sec=8192, 1/sec=16384/60=273 */
  290.    WORD   active;   /* lo bit 0=no cycle, 1=yes; next bit 1=rvs */
  291.    UBYTE   low;      /* range lower */
  292.    UBYTE   high;      /* range upper */
  293.    } CrngChunk;
  294.  
  295.  
  296.    /* ======================== CCRT =============================== */
  297.  
  298. typedef struct {
  299.    WORD   direction;      /* 0=don't cycle, 1=forward, -1=backwards */
  300.    UBYTE   start;         /* range lower */
  301.    UBYTE   end;            /* range upper */
  302.    LONG   seconds;         /* seconds between cycling */
  303.    LONG   microseconds;   /* msecs between cycling */
  304.    WORD   pad;            /* future exp - store 0 here */
  305.    } CcrtChunk;
  306.  
  307.  
  308.    /* =========================== ANHD ============================== */
  309.  
  310.    /* operation modes */
  311. #define   DirectSet      0
  312. #define   XOR            1
  313. #define   LongDelta      2
  314. #define   ShortDelta      3
  315. #define   ShortLong      4
  316. #define   ByteVertical   5
  317. #define   Juggler         74
  318.  
  319.    /* Bits values */
  320. #define   ShortData      0
  321. #define   LongData         1
  322. #define   Set            0
  323. #define   Xor            2
  324. #define   SeparateInfo   0
  325. #define   OneInfoList      4
  326. #define   NotRLC         0
  327. #define   RLC            8
  328. #define   Horizontal      0
  329. #define   Vertical         16
  330. #define   ShortInfo      0
  331. #define   LongInfo         32
  332.  
  333. typedef struct {
  334.    UBYTE operation;
  335.    UBYTE mask;
  336.    UWORD w,h;
  337.    WORD   x,y;
  338.    ULONG   abstime;
  339.    ULONG reltime;
  340.    UBYTE interleave;
  341.    UBYTE AnhdPad0;
  342.    ULONG Bits;
  343.    UBYTE AnhdPad[16];
  344.    } AnhdChunk;
  345.  
  346.    /* ===================== ILBMFrame STRUCTURE ===================== */
  347.  
  348. typedef struct {
  349.    UBYTE iFlags;
  350.    UBYTE iUserFlags;
  351.    BitMapHeader iBMHD;
  352.    ULONG   iViewModes;
  353.    Color4 iColorTable[maxColorReg];
  354.    UBYTE   iNumColors;
  355.    UBYTE iCycleCnt;
  356.    CrngChunk iCRNG[maxCycles];
  357.    struct Window *iWindow;
  358.    struct Screen *iScreen;
  359.    struct BitMap *iBMAP;
  360.    ULONG   iBMSize;
  361.    } ILBMFrame;
  362.  
  363.    /* definitions for iFlags field */
  364. #define   BMHDFLAG   1   /* if a BMHD chunk found in the file */
  365. #define   CAMGFLAG 2   /* if a CAMG chunk found */
  366. #define   ANHDFLAG 4   /* if an ANHD chunk found. This is for the use of your
  367.                      custom CHUNKhandler or PROPhandler. */
  368.  
  369.    /* definitions for iUserFlags. These must be initialized by you. */
  370. #define   MOUSEFLAG    1      /* no visible mouse pointer */
  371. #define   SCREENFLAG   2      /* hides screen title bar */
  372. #define   COLORFLAG   4      /* for "Don't use loaded colorMap. Preserve present map."*/
  373. #define   NOSCALE     8      /* "Don't scale a lower res pic to fill a higher res display */
  374. #define  ADJUSTVIEW  0x10   /* Do overscan if larger than Intuition view */
  375. #define   FORCEPARSE   0x20   /* Continue parsing after ANIM */
  376.  
  377. #define   ANIMFLAG      0x80      /* if an ANIM file */
  378.  
  379.  
  380.    /* ================== ILBMPropFrame STRUCTURE =================== */
  381.    /* Defines for the ILBMPropFrame, because you'll reference from the
  382.        ILBMFrame field when using GetPROPStruct, SearchPROP, CopyILBMProp. */
  383. #define   iNext      -10
  384. #define   iID      -6
  385. #define   iPFSize   -2
  386.  
  387.    /* The ILBMPropFrame structure actually looks like this: */
  388. typedef struct {
  389.    struct   ILBMPropFrame *NextPropFrame;
  390.    LONG      ifID;
  391.    UWORD      PropFrameSize;
  392.    ILBMFrame PropFrame;           /* The address of this field is returned
  393.                                  by the lib PROP routines so that you can
  394.                                  treat it just like an ordinary ILBMFrame */
  395.    } ILBMPropFrame;
  396.  
  397.  
  398.    /* =================== PROPList STRUCTURE =================== */
  399.  
  400. typedef struct {
  401.    struct   ILBMPropFrame *FirstPropFrame;
  402.    UWORD   NumPropFrames;
  403.    }   PROPList;
  404.  
  405.  
  406.    /* =================== Vectors STRUCTURE ==================== */
  407. /* When using mid-level load routines, you must allocate and initialize a
  408.    vector structure. This structure holds the addresses of whatever routines
  409.    you would like the lib to execute while parsing an IFF file. If the
  410.    vector address is 0, then the default lib routine is used. */
  411.  
  412. typedef IFFP ClientProc();
  413.  
  414. typedef struct _Vectors {
  415.  ClientProc *PROPhandler;
  416.    /*   address of routine to handle nonILBM 'PROP's or an ILBM
  417.       PROP chunk that is "unknown" to the lib (i.e. ANHD,DEST,
  418.       GRAB,SPRT,DLTA). If NULL, skips nonILBM PROPs. */
  419.  ClientProc *FORMhandler;
  420.    /* If not NULL, replaces the lib's default 'FORM' handler. */
  421.  ClientProc *CHUNKhandler;
  422.    /* Called by lib's default 'FORM' handler when it encounters
  423.       "unknown" chunks inside an ILBM (see PROPhandler). If NULL,
  424.       unknown chunks are skipped. If you don't use the lib's
  425.       default 'FORM' handler, then this field is free to use. */
  426.  ClientProc *NonILBMhandler;
  427.    /* Called by lib's default 'FORM' handler when it encounters
  428.        a FORM other than ILBM (i.e. 8SVX, etc). If NULL,
  429.       nonILBM FORMs are skipped. If you don't use the lib's
  430.       default 'FORM' handler, then this field is free to use. */
  431.    } Vectors;
  432.  
  433.  
  434.    /* ================== Lib Reader Routines ================= */
  435.  
  436. #ifdef  FDwAT
  437.  
  438. extern IFFP OpenRIFF( BPTR, GroupContext *, ULONG );
  439. extern IFFP OpenRGroup( GroupContext *, GroupContext * );
  440. extern IFFP CloseRGroup( GroupContext * );
  441. extern ID   GetChunkHdr( GroupContext * );
  442. extern IFFP IFFReadBytes( LONG, GroupContext *, BYTE * );
  443. extern ID   GetFChunkHdr( GroupContext * );
  444. extern ID   GetF1ChunkHdr( GroupContext * );
  445. extern ID   GetPChunkHdr( GroupContext * );
  446. extern IFFP SkipFwd( GroupContext *, LONG );
  447. extern IFFP FileLength( BPTR );
  448. extern void DecodeVKPlane( ULONG, WORD *, BYTE *, BYTE * );
  449. extern void MakeYTable( ULONG, ULONG, WORD * );
  450. extern void DecompDLTA( BYTE *, struct BitMap * );
  451. extern void DecompBODY( BYTE *, BitMapHeader *, struct BitMap * );
  452. extern void SetupBitmap( UWORD *, struct BitMap *, BitMapHeader * );
  453.  
  454. extern ULONG GetPROPStruct( ULONG, ID, PROPList * );
  455. extern ULONG SearchPROP( ID, PROPList * );
  456. extern void  FreePROPStruct( PROPList * );
  457. extern void  CopyILBMPropF( ILBMFrame *, ILBMFrame * );
  458.  
  459. extern IFFP   HandleCAMG( GroupContext *, ILBMFrame * );
  460. extern IFFP   HandleCCRT( GroupContext *, ILBMFrame * );
  461. extern IFFP   HandleCRNG( GroupContext *, ILBMFrame * );
  462. extern IFFP   GetCMAP( GroupContext *, WORD *, UBYTE * );
  463. extern IFFP   GetBODY( struct BitMap *, BYTE *, GroupContext *, BitMapHeader * );
  464.  
  465. /* GetBODY can handle a file with up to 16 planes plus a mask.*/
  466. #define MaxSrcPlanes 16+1
  467.  
  468. /* This macro computes the worst case packed size of a "row" of bytes. */
  469. #define MaxPackedSize(rowSize)  ( (rowSize) + ( ((rowSize)+127) >> 7 ) )
  470.  
  471. extern BOOL UnPackRow( ULONG, ULONG, BYTE *, BYTE * );
  472.  
  473. extern IFFP LoadILBM( BPTR, Vectors *, ILBMFrame * );
  474. extern IFFP LoadIFF( BPTR, Vectors *, ULONG );
  475. extern IFFP LoadIFFToWindow( BPTR, ILBMFrame * );
  476.  
  477. /* Note: Just call IFFReadBytes to read a BMHD, GRAB, DEST, SPRT, or CAMG
  478.    chunk. As below. */
  479. #define GetBMHD( context, bmHdr )  \
  480.     IFFReadBytes( sizeof(BitMapHeader), context, (BYTE *)bmHdr )
  481. #define GetGRAB( context, point2D )  \
  482.     IFFReadBytes( sizeof(Point2D) ,context, (BYTE *)point2D )
  483. #define GetDEST( context, destMerge )  \
  484.     IFFReadBytes( sizeof(DestMerge) ,context, (BYTE *)destMerge )
  485. #define GetSPRT( context, spritePrec )  \
  486.     IFFReadBytes( sizeof(SpritePrecedence) ,context, (BYTE *)spritePrec )
  487. #define GetCAMG( context, camg )  \
  488.     IFFReadBytes( sizeof(CamgChunk) ,context, (BYTE *)camg )
  489. #define   GetCRNG( context, crng )  \
  490.    IFFReadBytes( sizeof(CrngChunk) ,context, (BYTE *)crng )
  491. #define   GetCCRT( context, ccrt )  \
  492.    IFFReadBytes( sizeof(CcrtChunk) ,context, (BYTE *)ccrt )
  493. #define   GetANHD( context, anhd )  \
  494.    IFFReadBytes( sizeof(AnhdChunk) ,context, (BYTE *)anhd )
  495.  
  496.  
  497. extern BOOL ScaleImage( struct Rectangle *, struct Rectangle *, struct BitMap *,  struct RastPort * );
  498.  
  499.    /* ================= Low Level IFF Writer ======================== */
  500.  
  501. extern IFFP OpenWIFF( LONG, BPTR, GroupContext * );
  502. extern IFFP StartWGroup( ID, LONG, ID, GroupContext *, GroupContext * );
  503. extern IFFP EndWGroup( GroupContext * );
  504. extern IFFP OpenWGroup( GroupContext *, GroupContext * );
  505. extern IFFP CloseWGroup( GroupContext * );
  506. extern IFFP PutCk( ID, LONG, GroupContext *, BYTE * );
  507. extern IFFP PutCkHdr( ID, LONG, GroupContext * );
  508. extern IFFP IFFWriteBytes( LONG, GroupContext *, BYTE * );
  509. extern IFFP PutCkEnd( GroupContext * );
  510. extern ULONG PackRow( ULONG, BYTE *, BYTE * );
  511. extern IFFP InitBMHdr( ULONG, ULONG, ULONG, ULONG, ULONG, BitMapHeader *, struct BitMap * );
  512.  
  513. extern IFFP PutCMAP( UBYTE, GroupContext *, WORD );
  514. extern IFFP PutBODY( BYTE *, GroupContext *, BitMapHeader *, struct BitMap * );
  515.  
  516. extern IFFP SaveILBM( ULONG, ULONG, BPTR, BYTE *, UWORD *, struct BitMap *, Point2D *, ClientProc * );
  517. extern IFFP SaveANIM( ULONG, ULONG, BPTR, BYTE *, UWORD *, struct BitMap *, Point2D *, ClientProc *, AnhdChunk * );
  518. extern IFFP SaveWindowToIFF( BPTR, struct Window * );
  519.  
  520. /* Note: Just call PutCk to write a BMHD, GRAB, DEST, SPRT, or CAMG
  521.    chunk. As below. */
  522. #define PutBMHD( context, bmHdr )  \
  523.     PutCk( ID_BMHD, sizeof(BitMapHeader), context, (BYTE *)bmHdr )
  524. #define PutGRAB( context, point2D )  \
  525.     PutCk( ID_GRAB, sizeof(Point2D), context, (BYTE *)point2D )
  526. #define PutDEST( context, destMerge )  \
  527.     PutCk( ID_DEST, sizeof(DestMerge), context, (BYTE *)destMerge )
  528. #define PutSPRT( context, spritePrec )  \
  529.     PutCk( ID_SPRT, sizeof(SpritePrecedence), context, (BYTE *)spritePrec )
  530. #define PutANHD( context, AnhdChunk )  \
  531.     PutCk( ID_ANHD, sizeof(AnhdChunk), context, (BYTE *)AnhdChunk )
  532. #define PutCAMG( context, CamgChunk )  \
  533.     PutCk( ID_CAMG, sizeof(CamgChunk), context, (BYTE *)CamgChunk )
  534. #define PutCRNG( context, CrngChunk )  \
  535.     PutCk( ID_CRNG, sizeof(CrngChunk), context, (BYTE *)CrngChunk )
  536. #define PutCCRT( context, CcrtChunk )  \
  537.     PutCk( ID_CCRT, sizeof(CcrtChunk), context, (BYTE *)CcrtChunk )
  538.  
  539.  
  540. extern APTR GetIFFPMsg( IFFP );
  541. extern void BlankPointer( struct Window * );
  542.  
  543. #else
  544.  
  545. extern IFFP OpenRIFF();
  546. extern IFFP OpenRGroup();
  547. extern IFFP CloseRGroup();
  548. extern ID   GetChunkHdr();
  549. extern IFFP IFFReadBytes();
  550. extern ID   GetFChunkHdr();
  551. extern ID   GetF1ChunkHdr();
  552. extern ID   GetPChunkHdr();
  553. extern IFFP SkipFwd();
  554. extern IFFP FileLength();
  555. extern void DecodeVKPlane();
  556. extern void MakeYTable();
  557. extern void DecompDLTA();
  558. extern void DecompBODY();
  559. extern void SetupBitmap();
  560.  
  561. extern ULONG GetPROPStruct();
  562. extern ULONG SearchPROP();
  563. extern void  FreePROPStruct();
  564. extern void  CopyILBMPropF();
  565.  
  566. extern IFFP   HandleCAMG();
  567. extern IFFP   HandleCCRT();
  568. extern IFFP   HandleCRNG();
  569. extern IFFP   GetCMAP();
  570. extern IFFP   GetBODY();
  571.  
  572. /* GetBODY can handle a file with up to 16 planes plus a mask.*/
  573. #define MaxSrcPlanes 16+1
  574.  
  575. /* This macro computes the worst case packed size of a "row" of bytes. */
  576. #define MaxPackedSize(rowSize)  ( (rowSize) + ( ((rowSize)+127) >> 7 ) )
  577.  
  578. extern BOOL UnPackRow();
  579.  
  580.  
  581. extern IFFP LoadILBM();
  582. extern IFFP LoadIFF();
  583. extern IFFP LoadIFFToWindow();
  584.  
  585. /* Note: Just call IFFReadBytes to read a BMHD, GRAB, DEST, SPRT, or CAMG
  586.    chunk. As below. */
  587. #define GetBMHD(context, bmHdr)  \
  588.     IFFReadBytes(sizeof(BitMapHeader), context, (BYTE *)bmHdr)
  589. #define GetGRAB(context, point2D)  \
  590.     IFFReadBytes(sizeof(Point2D) ,context, (BYTE *)point2D)
  591. #define GetDEST(context, destMerge)  \
  592.     IFFReadBytes(sizeof(DestMerge) ,context, (BYTE *)destMerge)
  593. #define GetSPRT(context, spritePrec)  \
  594.     IFFReadBytes(sizeof(SpritePrecedence) ,context, (BYTE *)spritePrec)
  595. #define GetCAMG(context, camg)  \
  596.     IFFReadBytes(sizeof(CamgChunk) ,context, (BYTE *)camg)
  597. #define   GetCRNG(context, crng)  \
  598.    IFFReadBytes(sizeof(CrngChunk) ,context, (BYTE *)crng)
  599. #define   GetCCRT(context, ccrt)  \
  600.    IFFReadBytes(sizeof(CcrtChunk) ,context, (BYTE *)ccrt)
  601. #define   GetANHD(context, anhd)  \
  602.    IFFReadBytes(sizeof(AnhdChunk) ,context, (BYTE *)anhd)
  603.  
  604.  
  605.    /* ================= Low Level IFF Writer ======================== */
  606.  
  607. extern IFFP OpenWIFF();
  608. extern IFFP StartWGroup();
  609. extern IFFP EndWGroup();
  610. extern IFFP OpenWGroup();
  611. extern IFFP CloseWGroup();
  612. extern IFFP PutCk();
  613. extern IFFP PutCkHdr();
  614. extern IFFP IFFWriteBytes();
  615. extern IFFP PutCkEnd();
  616. extern ULONG PackRow();
  617. extern IFFP InitBMHdr();
  618.  
  619. extern IFFP PutCMAP();
  620. extern IFFP PutBODY();
  621.  
  622.  
  623. extern IFFP SaveILBM();
  624. extern IFFP SaveANIM();
  625. extern IFFP SaveWindowToIFF();
  626.  
  627. extern BOOL ScaleImage();
  628.  
  629. /* Note: Just call PutCk to write a BMHD, GRAB, DEST, SPRT, or CAMG
  630.    chunk. As below. */
  631. #define PutBMHD(context, bmHdr)  \
  632.     PutCk(ID_BMHD, sizeof(BitMapHeader), context, (BYTE *)bmHdr)
  633. #define PutGRAB(context, point2D)  \
  634.     PutCk(ID_GRAB, sizeof(Point2D), context, (BYTE *)point2D)
  635. #define PutDEST(context, destMerge)  \
  636.     PutCk(ID_DEST, sizeof(DestMerge), context, (BYTE *)destMerge)
  637. #define PutSPRT(context, spritePrec)  \
  638.     PutCk(ID_SPRT, sizeof(SpritePrecedence), context, (BYTE *)spritePrec)
  639. #define PutANHD(context, AnhdChunk)  \
  640.     PutCk(ID_ANHD, sizeof(AnhdChunk), context, (BYTE *)AnhdChunk)
  641. #define PutCAMG(context, CamgChunk)  \
  642.     PutCk(ID_CAMG, sizeof(CamgChunk), context, (BYTE *)CamgChunk)
  643. #define PutCRNG(context, CrngChunk)  \
  644.     PutCk(ID_CRNG, sizeof(CrngChunk), context, (BYTE *)CrngChunk)
  645. #define PutCCRT(context, CcrtChunk)  \
  646.     PutCk(ID_CCRT, sizeof(CcrtChunk), context, (BYTE *)CcrtChunk)
  647.  
  648.  
  649. extern APTR GetIFFPMsg();
  650. extern void BlankPointer();
  651.  
  652. #endif
  653.  
  654. typedef UBYTE *UBytePtr;
  655.  
  656. #endif ILBMLIB_H
  657.  
  658.  
  659.